package com.acom.bootredis.controller;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.acom.bootredis.util.R;

@RestController
@RequestMapping("/redis")
public class TestRedisController {
	@Autowired
	private StringRedisTemplate stringRedisTemplate;
	@Autowired
	private RedisTemplate<String,String> redisTemplate;
	@RequestMapping("/list")
    public R redisHandler() {
    	R r  = new R();
    	List<String> list = new ArrayList<>();
    	//stringRedisTemplate.opsForValue().set("k5", "qw");
    	//stringRedisTemplate.opsForValue().set("k6", "中文乱码吗");
    	list.add(stringRedisTemplate.opsForValue().get("k5"));
    	list.add(stringRedisTemplate.opsForValue().get("k6"));
    	redisTemplate.opsForValue().set("k8", "中文可以不");
    	list.add(redisTemplate.opsForValue().get("k8").toString());
    	list.add(redisTemplate.getKeySerializer().toString());
    	r.setData(list);
    	return r;
    }
}
